from model.dashscope import DashscopeModel
from model.model import Model

from utils import ConfigLoader, LOG
from translator import PDFTranslator

if __name__ == "__main__":

    config_loader = ConfigLoader("./utils/config.yaml")
    config = config_loader.load_config()
    
    model_name = config['DashscopeModel']['model']
    api_key = config['DashscopeModel']['api_key']
    model = DashscopeModel(model_name=model_name, api_key=api_key)
    
    """ prompt = model.make_text_prompt("i am chinese", '中文')
    print(prompt)
    res, code = model.make_request(prompt=prompt)
    print(res)
    quit() """

    pdf_file_path = config['common']['book']
    file_format = config['common']['file_format']
    target_language = config['common']['target_language']
    # 实例化 PDFTranslator 类，并调用 translate_pdf() 方法
    translator = PDFTranslator(model)
    translator.translate_pdf(pdf_file_path, file_format,target_language=target_language)
